//
//  BlogViewController.m
//  iWeddingDirectory
//
//  Created by Tung Ngo on 5/24/12.
//  Copyright (c) 2012 Home. All rights reserved.
//

#import "BlogViewController.h"

@implementation BlogViewController
@synthesize webViewBlog;
@synthesize activityIndicator;

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
        UITabBarItem *item = [[UITabBarItem alloc] initWithTitle:@"Blog" image:[UIImage imageNamed:@"blog.png"] tag:0];
        self.tabBarItem = item;
        [item release];
    }
    return self;
}

- (void)didReceiveMemoryWarning
{
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Release any cached data, images, etc that aren't in use.
}

#pragma mark - View lifecycle

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    self.title = @"Blog";
    self.navigationController.navigationBar.barStyle = UIBarStyleBlackOpaque;
    [webViewBlog loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://iweddingdirectory.com.au/iwed/iwed/article-category/blog"]]];
}

- (void)viewDidUnload
{
    [self setActivityIndicator:nil];
    [self setWebViewBlog:nil];
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

- (void)dealloc {
    [activityIndicator release];
    [webViewBlog release];
    [super dealloc];
}

#pragma mark - Web view delegate

- (void)webViewDidStartLoad:(UIWebView *)webView
{
    [activityIndicator setHidden:NO];
    [activityIndicator startAnimating];
}

- (void)webViewDidFinishLoad:(UIWebView *)webView
{
    [activityIndicator stopAnimating];
}

@end
